package com.xzit.xzitexprement2.Controller;

import com.xzit.xzitexprement2.Pojo.grades;
import com.xzit.xzitexprement2.Pojo.result;
import com.xzit.xzitexprement2.Service.gradesService;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/grades")
public class gradesController {
    @Autowired
    private gradesService gradesservice;
    @GetMapping("/listAll")
    public result listAll(){
        return result.success(gradesservice.listAll());
    }
    @GetMapping("/getByCourseId/{cid}")
    public result getByCourseId(@PathVariable Integer cid){
        return result.success(gradesservice.getByCourseId(cid));
    }
    @PostMapping("/update")
    public result update(@RequestBody grades grades){
        gradesservice.update(grades);
        return result.success();
    }
    @GetMapping("/getByRange/{minscore}/{maxscore}")
    public result getByRange(@PathVariable Integer minscore,@PathVariable Integer maxscore){
        return result.success(gradesservice.getByRange(minscore,maxscore));
    }
}
